﻿using UnityEngine;
using System.Collections;
using Pathfinding;

public class CitizenModel : MonoBehaviour {
	
	[SerializeField]
	public GameObject modelCitizen;
	[SerializeField]
	public float _nextWaypointDistance = 3;
	[SerializeField]
	public float _speed = 100;
	[SerializeField]
	public float _turningSpeed =10;
    [SerializeField]
    public string _name = "";
    [SerializeField]
    public string _walkANimation = "";
    [SerializeField]
    public string _runAnimation = "";
    [SerializeField]
    public Rigidbody modelElement;

    private Animation _animation;
	private Seeker _seeker;
	private Citizen classCitizen;

    #region Get Components
    /// <summary>
	/// Return the Class Citzen associate to the NPC
	/// </summary>
	/// <returns>Class Citizen</returns>
	public Citizen GetCitizen()
	{
		if(classCitizen == null){
			classCitizen = new Citizen();
			
		}
		return classCitizen;
	}

    /// <summary>
    /// Return the Model ASociate to the NPC
    /// </summary>
    /// <returns>Model of the object</returns>
	public GameObject GetModelCitizen()
	{
		return modelCitizen;
	}

    public Rigidbody GetModelElement()
    {
        return modelElement;
    }

    /// <summary>
    /// Return the Class Seeker associate to the NPC
    /// </summary>
    /// <returns>Class Seeker</returns>
	public Seeker GetSeeker()
	{
		if(_seeker == null)
		{
			_seeker = this.GetComponent<Seeker>();
		}
		return _seeker;
	}
	
    /// <summary>
    /// Return the movement speed of the NPC
    /// </summary>
    /// <returns>Movement speed</returns>
	public float GetSpeed()
	{
		return _speed;
	}
	
    /// <summary>
    /// Return the turning spedd of the NPC
    /// </summary>
    /// <returns>Turning speed</returns>
	public float GetTurningSpeed()
	{
		return _turningSpeed;
	}

    public Animation GetAnimation()
    {
        return _animation;
    }

    #endregion

    void Start () {
		GetCitizen();
		_seeker = this.GetComponent<Seeker>();
        //_animation = this.GetComponent<Animation>();
		classCitizen.oCitizen = GetModelCitizen();
		classCitizen.cController = GetModelCitizen().GetComponent<CharacterController>();
	}
}
